﻿#include "mainform.h"
#include "ui_mainform.h"

#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QTabWidget>
#include <QToolBox>


MainForm::MainForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MainForm)
{
    ui->setupUi(this);

//    qssFile = new QFile(":/qss/white", this);
//    qssFile->open(QFile::ReadOnly);
//    QString styleSheet = tr(qssFile->readAll());

//    qApp->setStyleSheet(styleSheet);
//    qssFile->close();

    QPalette topBg = this->palette();
    topBg.setColor(QPalette::Background, QColor(17,90,169));
    this->setAutoFillBackground(true);
    this->setPalette(topBg);


    QVBoxLayout *mainLayout = new QVBoxLayout;
    QHBoxLayout *topLayout = new QHBoxLayout;
    QHBoxLayout *bottomLayout = new QHBoxLayout;

    QLabel *logoLabel = new QLabel;

    QPixmap pixmap(":/images/logo");
    logoLabel->setFixedSize(274, 71);
    logoLabel->setPixmap(pixmap);
    logoLabel->setScaledContents(true);

    QPushButton *logoutBtn = new QPushButton(tr("Logout"));

    //抽屉效果
    QToolBox *mainToolBox = new QToolBox;
    mainToolBox->setMaximumWidth(200);
    QPushButton *btnNew1 = new QPushButton(tr("new1"));
    QPushButton *btnNew2 = new QPushButton(tr("new2"));
    QPushButton *btnNew3 = new QPushButton(tr("new2"));

    QWidget *page = new QWidget;
    QVBoxLayout *layout = new QVBoxLayout(page);
    layout->addWidget(btnNew1);
    layout->addWidget(btnNew2);
    mainToolBox->addItem(page, tr("new1"));

    page = new QWidget;
    layout = new QVBoxLayout(page);
    layout->addWidget(btnNew3);
    mainToolBox->addItem(page, tr("new2"));


    this->setLayout(mainLayout);
    mainLayout->addLayout(topLayout);
    mainLayout->addLayout(bottomLayout);

    bottomLayout->addWidget(mainToolBox);

    QGridLayout *mainContent = new QGridLayout;
    mainContent->addWidget(btnNew1);
    bottomLayout->addLayout(mainContent);

    topLayout->addWidget(logoLabel);
    topLayout->addWidget(logoutBtn);

}

MainForm::~MainForm()
{
    delete ui;
}
